﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Areas/Admin/Views/Shared/AdminSite.Master"
    Inherits="System.Web.Mvc.ViewPage<IEnumerable<HYBYSoft.Company.Models.Category>>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Index
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <div id="content">
        <div id="div_search">
            <table cellpadding="0" cellspacing="0" border="0" width="100%">
                <tr>
                    <td id="left_search">
                    </td>
                    <td id="bg_search">
                        <p>
                            <span id="sitemap">当前位置：</span>
                        </p>
                        <%using (Html.BeginForm("Search", "Category"))
                          {%>
                        <p>
                            类别名称：<%= Html.TextBox("txtCategoryName", null, new { style = "width:180px;margin-right:15px" })%>
                            是否启用：<%= Html.DropDownList("isState", (IEnumerable<SelectListItem>)ViewData["isState"], new { style = "width:110px;margin-right:15px" })%>
                            <input type="submit" value="查询" />
                        </p>
                        <%} %>
                    </td>
                    <td id="right_search">
                    </td>
                </tr>
            </table>
        </div>
        <div id="div_list">
            <%if (Model.Count() == 0)
              {
                  Html.RenderPartial("partialNoneDate");
              }
              else
              {%>
            <% var grid = new WebGrid(source: Model, defaultSort: "ParentID", rowsPerPage: 10, canSort: false); %>
            <%=grid.GetHtml(tableStyle: "grid", headerStyle: "header",rowStyle:"row", alternatingRowStyle: "alt", footerStyle:"footer",
                            mode:WebGridPagerModes.All, firstText:"首页", previousText:"上一页", nextText:"下一页", lastText:"尾页",
                            columns: grid.Columns(
                                                                    grid.Column("类别名称", format: (item) => Html.ActionLink(((Category)((WebGridRow)item).Value).Name, "Details", new { id = item.CategoryID })),
                                                  grid.Column("是否启用", format: (item) => Html.Encode(((Category)((WebGridRow)item).Value).State==1?"是":"否")),
                                                  grid.Column("父级菜单",format: (item) => Html.Encode(((Category)((WebGridRow)item).Value).ParentName)),
                                                  grid.Column("编辑类别",format: (item) => Html.ActionLink("编辑", "Edit", new { id = item.CategoryID }), style: "buttoncolumn"),
                                                  grid.Column("是否启用", format: (item) => Html.ActionLink(((Category)((WebGridRow)item).Value).State == 0 ? "启用" : "禁用", "Delete", new { id = item.CategoryID }, new { onclick = "return confirm('确定更改现有状态？');" }), style: "buttoncolumn")
                                                 )
                            )%>
            <%} %>
        </div>
        <p>
            <%: Html.ActionLink("新建类别", "Create") %>
        </p>
    </div>
</asp:Content>
